﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Neeko.XNA.UI
{
    public class MultilineLabel
    {
        public Vector2 Position { get; set; }
        public Color Color { get; set; }
        public String Text { get; set; }

        public SpriteFont SpriteFont { get; set; }


        public MultilineLabel()
        {
            this.SpriteFont = UIResourceRepository.UIFont;
            this.Color = Color.White;
            this.Text = "";
        }

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if (!String.IsNullOrEmpty(this.Text))
            {
                String[] lines = this.Text.Split('\n');
                Vector2 size = this.SpriteFont.MeasureString(lines[0]);

                for (int i = 0; i < lines.Length; i++)
                {
                    spriteBatch.DrawString(this.SpriteFont, lines[i], this.Position + new Vector2(0, size.Y + 1) * i - Vector2.One / 2, Color.Black);
                    spriteBatch.DrawString(this.SpriteFont, lines[i], this.Position + new Vector2(0, size.Y + 1) * i, this.Color);
                }

            }
        }
    }
}
